package org.rbac.web.filter.logicFilter;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.rbac.util.SqlCmdUtil;

import com.kingschan.easyquery.logic.SuffixFilter;
import com.kingschan.easyquery.logic.handle.dispacher.LogicHandleDispacher;
import com.kingschan.easyquery.logic.handle.inital.ScanArgsLogicHandle;
import com.kingschan.easyquery.logic.handle.inital.WhereLogicHandle;
import com.kingschan.easyquery.logic.handle.query.PaginationQueryLogicHandle;
import com.kingschan.easyquery.logic.handle.query.TotalLogicHandle;
import com.kingschan.easyquery.output.impl.GridOutPut;
import com.kingschan.easyquery.vo.SqlCommand;
/**
 * 
*  <pre>    
* 类名称：GridFilter 
* 类描述：   表格查询逻辑处理
* 创建人：陈国祥   (kingschan)
* 创建时间：2015-4-2 下午4:25:45   
* 修改人：Administrator   
* 修改时间：2015-4-2 下午4:25:45   
* 修改备注：   
* @version V1.0
* </pre>
 */
public class GridFilter implements SuffixFilter{

    @SuppressWarnings("unchecked")
    @Override
    public void doFilter(HttpServletRequest req, HttpServletResponse rep, Map<String, Object> args)
            throws Exception {
        LogicHandleDispacher dispa = new LogicHandleDispacher(req, rep);
        SqlCommand cmd =null;
//        if (target.matches("[a-zA-Z0-9]{32}")) {
//           // cmd = ActionUtil.getCmdById(target);
//        }else{
            //xml
            SqlCmdUtil sc = new SqlCmdUtil();   
            String [] data=args.get("$action").toString().replaceAll("^/", "").split("/");
            cmd =sc.getSqlCmdById(data[0],data[1]);
//        }
        dispa.handleDispacher(args,cmd, new GridOutPut(),
            new Class[]{
                WhereLogicHandle.class,
                ScanArgsLogicHandle.class,
                TotalLogicHandle.class,
                PaginationQueryLogicHandle.class
            });
    }
    
   

}
